<?php
namespace app\index\model;

use think\Model;

class User extends Model{
    public function teacher(){
        $data = $this->where('userstatus','1')->select();
        return $data;
    }

    public function student(){
        $data = $this->where('userstatus','0')->select();
        return $data;
    }

    //修改数据库的状态（0/1）
    public function setStatus($status,$ids){
        $map["id"] = ["IN","$ids"];
        return $this->where($map)->update(["status"=>$status]);
    }

    public function SC($id){
        $data= $this->alias('s')
                    ->join('sc a','s.Id = a.S_Id')
                    ->join('course c','a.C_Id = c.Id')
                    ->where('s.Id',$id)
                    ->order('istop desc')
                    ->select();
        return $data;
    }

    public function TC($id){
        $data= $this->alias('t')
                    ->join('tc a','t.Id = a.t_Id')
                    ->join('course c','a.C_Id = c.Id')
                    ->where('t.Id',$id)
                    ->order('istop desc')
                    ->select();
        return $data;
    }

    public function clastu($id){
        $data= $this->alias('u')
                    ->join('ss s','u.Id = s.student_Id')
                    ->join('classes cla','s.class_Id = cla.Id')
                    ->where('cla.Id',$id)
                    ->select();
        // echo $this->getLastSql();
        return $data;
    }

    public function newstudent($userId){
        $data = $this->where('userId',$userId)->where('userstatus',0)->find();
        
        return $data;
    }
}
?>